package com.ophiux.rocket.producer;

import com.ophiux.rocket.dto.UserEntity;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;

import java.util.function.Supplier;

@Configuration
public class SendMQ {
    Integer i = 1;

    @Bean
    public Supplier<Message<UserEntity>> myTopicP() {
        return () -> {
            UserEntity entity = new UserEntity();
            entity.setPass(i++ + "");
            entity.setName(Thread.currentThread().getName());
            System.out.println("myTopicP 发送一条记录：" + entity);
            return MessageBuilder.withPayload(entity).build();
        };
    }
}
